package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsHotels;
import com.hbms.business.service.IHotelbmsHotelsService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 酒店信息Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/hotels")
public class HotelbmsHotelsController extends BaseController
{
    @Autowired
    private IHotelbmsHotelsService hotelbmsHotelsService;

    /**
     * 查询酒店信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsHotels hotelbmsHotels)
    {
        startPage();
        List<HotelbmsHotels> list = hotelbmsHotelsService.selectHotelbmsHotelsList(hotelbmsHotels);
        return getDataTable(list);
    }

    /**
     * 导出酒店信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:export')")
    @Log(title = "酒店信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsHotels hotelbmsHotels)
    {
        List<HotelbmsHotels> list = hotelbmsHotelsService.selectHotelbmsHotelsList(hotelbmsHotels);
        ExcelUtil<HotelbmsHotels> util = new ExcelUtil<HotelbmsHotels>(HotelbmsHotels.class);
        util.exportExcel(response, list, "酒店信息数据");
    }

    /**
     * 获取酒店信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:query')")
    @GetMapping(value = "/{hotelId}")
    public AjaxResult getInfo(@PathVariable("hotelId") Long hotelId)
    {
        return success(hotelbmsHotelsService.selectHotelbmsHotelsByHotelId(hotelId));
    }

    /**
     * 新增酒店信息
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:add')")
    @Log(title = "酒店信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsHotels hotelbmsHotels)
    {
        return toAjax(hotelbmsHotelsService.insertHotelbmsHotels(hotelbmsHotels));
    }

    /**
     * 修改酒店信息
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:edit')")
    @Log(title = "酒店信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsHotels hotelbmsHotels)
    {
        return toAjax(hotelbmsHotelsService.updateHotelbmsHotels(hotelbmsHotels));
    }

    /**
     * 删除酒店信息
     */
    @PreAuthorize("@ss.hasPermi('business:hotels:remove')")
    @Log(title = "酒店信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotelIds}")
    public AjaxResult remove(@PathVariable Long[] hotelIds)
    {
        return toAjax(hotelbmsHotelsService.deleteHotelbmsHotelsByHotelIds(hotelIds));
    }
}
